-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: move to using Ruff #315
Conversation
henryiii
commented
Feb 17, 2023
- chore: move to using Ruff
- style: make Ruff happy
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
289a7d6
to
3a09183
Compare
len(returns) == 2 | ||
and isinstance(returns[0], type) | ||
and issubclass(returns[0], Azimuthal) | ||
and returns[1] is None | ||
): | ||
azcoords = _coord_object_type[returns[0]](result[0], result[1]) | ||
return cls.ProjectionClass2D(azimuthal=azcoords) | ||
|
||
elif ( | ||
len(returns) == 2 | ||
and isinstance(returns[0], type) | ||
and issubclass(returns[0], Azimuthal) | ||
and isinstance(returns[1], type) | ||
and issubclass(returns[1], Longitudinal) | ||
): | ||
azcoords = _coord_object_type[returns[0]](result[0], result[1]) | ||
lcoords = _coord_object_type[returns[1]](result[2]) | ||
return cls.ProjectionClass3D(azimuthal=azcoords, longitudinal=lcoords) | ||
|
||
elif ( | ||
len(returns) == 3 | ||
or (len(returns) == 3 and returns[2] is None) | ||
and isinstance(returns[0], type) | ||
and issubclass(returns[0], Azimuthal) | ||
and isinstance(returns[1], type) | ||
and issubclass(returns[1], Longitudinal) | ||
and returns[2] is None | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to manually make these changes, but pretty impressed Ruff noticed it could be made. :)
- id: flake8 | ||
additional_dependencies: | ||
- flake8-bugbear | ||
- flake8-docstrings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, Ruff's "D" code catches a lot of stuff the old one didn't. So I've removed it for now, and we can enable new codes (including "D") in the future.
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
3a09183
to
44f5cf2
Compare
@@ -694,7 +694,7 @@ def momentum_rhophizt(): | |||
assert out.pt == pytest.approx(2) | |||
assert out.phi == pytest.approx(3.3) | |||
assert out.z == pytest.approx(5) | |||
assert out.E == pytest.approx(10) | |||
assert out.E == pytest.approx(10) # noqa: SIM300 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yoda conditions thinks ".E" is a constant.
|
||
@numba.njit | ||
def get_false(v): | ||
return False if v else True | ||
return False if v else True # noqa: SIM211 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support not v
, which is a little strange, but just noqa'd it. not bool(v)
probably would have worked, since I think bool(v)
above worked. But that also might have been simplified by a SIM code.
Ruff looks amazing! 🤩 |